Skip to content

fix: allow adaptive thinking and xhigh effort with Claude Opus 4.7#9281

Open
Raptors65 wants to merge 9 commits into
mainfrom
lucask/fix/support-adaptive-thinking-with-opus-4-7
Open

fix: allow adaptive thinking and xhigh effort with Claude Opus 4.7#9281
Raptors65 wants to merge 9 commits into
mainfrom
lucask/fix/support-adaptive-thinking-with-opus-4-7

Conversation

@Raptors65
Copy link
Copy Markdown
Collaborator

@Raptors65 Raptors65 commented May 16, 2026

Summary

Claude Opus 4.7 has a few breaking changes with the Claude API: https://platform.claude.com/docs/en/about-claude/models/migration-guide

Currently, for Opus 4.7 with the Anthropic provider:

  • the displayed extended thinking modes are "Enabled" (with a fixed token budget) or "Disabled" (no extended thinking); adaptive thinking is not displayed as an option
  • if "Enabled" is selected, any messages fail with a 400 error, because Opus 4.7 doesn't support extended thinking
  • xhigh is not an option for effort; this is an thinking effort level that only exists on Opus 4.7
  • we don't emit thinking.display = "summarized", which means we use default behavior which in Opus 4.7 was changed to be to not emit reasoning at all
  • we pass temperature to the API call, which fails if it's set to any non-default value for Opus 4.7

This PR fixes this by:

  • adding Opus 4.7 as a "known model" in the Anthropic provider
  • adding xhigh as an effort level only for Opus 4.7, and making this the default for Opus 4.7 (this is the recommended default in the Claude docs)
  • disabling "extended thinking" for Opus 4.7 in favor of adaptive thinking
  • emitting thinking.display = "summarized" for all models with adaptive thinking (not technically needed for Sonnet 4.6 and Opus 4.6, but would rather be explicit there too)
  • omitting temperature for Opus 4.7

Testing

There are some unit tests, but also tested this manually.

CLI ("adaptive" instead of "enabled" mode displayed, xhigh effort available):

Opus.4.7.CLI.mov

Desktop app:

Screen.Recording.2026-05-16.at.1.06.21.PM.mov

Summarized thinking being displayed with Opus 4.7:

image

Related Issues

N/A

Screenshots/Demos (for UX changes)

Before:

After:

@Raptors65
Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Raptors65 Raptors65 force-pushed the lucask/fix/support-adaptive-thinking-with-opus-4-7 branch from b1c73dc to 184d306 Compare May 16, 2026 16:55
@Raptors65 Raptors65 marked this pull request as ready for review May 16, 2026 17:09
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 184d306a47

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +97 to +99
} else if is_adaptive_model {
ThinkingType::Adaptive
} else if std::env::var("CLAUDE_THINKING_ENABLED").is_ok() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Leave Opus 4.7 thinking disabled unless user enables it

This branch now defaults every adaptive-capable model to ThinkingType::Adaptive, which means claude-opus-4-7 requests get thinking turned on even when users did not configure any thinking mode. For Opus 4.7, that changes baseline behavior from "no thinking unless explicitly requested" to "always adaptive thinking", which can materially increase latency/token usage and alter response shape for existing users who only changed model IDs.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already what we do for other models that support adaptive thinking (Sonnet 4.6 / Opus 4.6), so seems to make sense to do that for Opus 4.7 too

Comment on lines +58 to +60
if is_claude_opus_47(model_name) {
ThinkingEffort::XHigh
} else {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep Opus 4.7 effort at API default unless configured

Setting Opus 4.7's implicit effort to xhigh forces a more expensive effort tier whenever users don't explicitly set CLAUDE_THINKING_EFFORT/effort. Since thinking_effort() uses this as the fallback, existing configurations that rely on defaults will silently run at higher cost/latency than the provider default. xhigh should be an explicit opt-in, not the fallback.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xhigh is the recommended default in the Claude docs for "coding and agentic work", which seems like the most likely kind of work someone would be using goose for, but open to having the default stay at high if we want to do that (high is the API default)

@shakoorshkh
Copy link
Copy Markdown

Observed:
Opus 4.7 rejects requests with extended thinking enabled, non-default temperature, or missing thinking.display = "summarized" — all silent 400 failures from upstream breaking changes.
Downside:
Opus 4.7 is now a special-cased model with divergent behavior from the rest of the Anthropic provider. That surface grows if Claude releases further model-specific API contracts.
Tradeoff:
Hardcoded model-specific logic over a generalized capability flag system. Faster to ship; accrues provider complexity with each future model that breaks convention.

@DOsinga DOsinga added the needs_human label to set when a robot looks at a PR and can't handle it label May 18, 2026
@jh-block jh-block force-pushed the lucask/fix/support-adaptive-thinking-with-opus-4-7 branch from 184d306 to 29ad7a3 Compare May 20, 2026 11:32
Raptors65 and others added 5 commits May 20, 2026 13:34
Use adaptive thinking when preserved Anthropic thinking context needs to synthesize a thinking config for adaptive Claude models. This keeps Opus 4.7 out of the fixed-budget path while preserving prior thinking blocks across continuation requests.

Signed-off-by: jh-block <jhugo@block.xyz>
Use the Anthropic API default effort when no unified thinking effort is configured. Explicit max still maps to xhigh for Opus 4.7, but an omitted effort now stays at high and is covered by a regression test.

Signed-off-by: jh-block <jhugo@block.xyz>
Preserve an unset unified thinking effort through provider formatting and the model switcher. Providers now only serialize effort fields when the user or legacy config explicitly sets an effort, allowing upstream API defaults to apply.

Signed-off-by: jh-block <jhugo@block.xyz>
Keep provider request formatting from inventing a thinking effort when none is configured, while making the desktop and CLI model-selection surfaces default explicit thinking effort to high for reasoning-capable models.

Signed-off-by: jh-block <jhugo@block.xyz>
@jh-block jh-block force-pushed the lucask/fix/support-adaptive-thinking-with-opus-4-7 branch from 29ad7a3 to 0638379 Compare May 20, 2026 11:36
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0638379368

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/goose/src/providers/formats/anthropic.rs Outdated
Signed-off-by: jh-block <jhugo@block.xyz>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12d93afa06

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/goose/src/providers/formats/anthropic.rs Outdated
Signed-off-by: jh-block <jhugo@block.xyz>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65cda3c96c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/goose-cli/src/commands/configure.rs
Signed-off-by: jh-block <jhugo@block.xyz>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fecbe0c81b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/goose/src/providers/formats/anthropic.rs Outdated
Signed-off-by: jh-block <jhugo@block.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs_human label to set when a robot looks at a PR and can't handle it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants